<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ include file="../../common/common.jsp" %>
<%@ include file="master_pass.jsp" %>
<HTML>
<HEAD>
<title>新建地区信息</title>
<%@ include file="../../common/meta.inc" %>
<link href="css.css" rel="stylesheet" type="text/css">
<base target="_self">
<SCRIPT LANGUAGE="javascript" SRC="${pageContext.request.contextPath}/scripts/common-validator.js"></SCRIPT>
<script language="javascript" src="${pageContext.request.contextPath}/scripts/prototype.js"></script>
<script language="javascript" src="${pageContext.request.contextPath}/scripts/buffalo/buffalo.js"></script>
<script language="javascript">
var END_POINT="${pageContext.request.contextPath}/buffalo";
var buffalo = new Buffalo(END_POINT);
function doSubmit() {

	form = document.theform;
	
	if(!validateForm(form))
		return;
		
		
    var obj = {};
	obj[Buffalo.BOCLASS] = "com.gouwudai.gobbs.pojo.TbbsArea";
	obj.areaType=parseInt($F('areaType'));
	obj.areaName=$F('areaName');
	var parentId = $('parentId').value;
	if(parentId==null||parentId=="")
		obj.parentId = 0;
	else
		obj.parentId = parseInt(parentId);		
	
    buffalo.remoteCall("areaServiceAjaxService.save",[obj], function(reply) {
         ajaxSubmit(reply.getResult(),null,"close");	
    });
}

function validateForm(form)
{
   	if(!sl_checkChoice(form.areaType,"地区类型")) return false;   	
    if(!sl_check(form.areaName,"地区名称",50,1)) return false;
     
    return sl_confirmUpdate();
}

function changeAreaType(areaType)
{
   	if(areaType.value=="0")
   		$('parentId').disabled = false;
   	else 
   	{  
   		$('parentId').selectedIndex = 0;
   		$('parentId').disabled = true;
   	}	
}

</script>
</HEAD>
<BODY leftMargin=0 topMargin=0 rightmargin="0" bottommargin="0" onkeydown="javascript:chachEsc(window.event.keyCode)">
<form name="theform" method="post" action="area_new.jsp">
						<table border="0" width="100%" cellspacing="0" cellpadding="0">
							<tr>
								<td><img border="0" src="${pageContext.request.contextPath}/club/admin/images/config.gif" align="absbottom"><font color="#215dc6"><b>新建地区信息</b></font></td>
							</tr>
							<tr>
								<td>
								<hr noshade color="#808080" size="1">
								</td>
							</tr>
						</table>
						<table border="0" width="100%" cellspacing="3">								
							<tr>
								<td width="46%" align="right">地区类型:</td>
								<td width="49%">
								<select size="1" name="areaType" id="areaType" onkeydown="javascript:nextKeyPress(this)" onchange="javascript:changeAreaType(this)">
									<%=Arguments.getDictParamOptions("S002",0)%>
								</select>
								</td>
							</tr>													
							<tr>
								<td width="46%" align="right">地区名称:</td>
								<td width="49%"><input type="text" name="areaName" id="areaName" onkeydown="javascript:nextKeyPress(this)" size="20"></td>
							</tr>	
							<tr>
								<td width="46%" align="right">父地区:</td>
								<td width="49%">
								<select size="1" name="parentId" id="parentId" onkeydown="javascript:nextKeyPress(this)">
									<%=Arguments.getProvinceOptions(0)%>
								</select>
								</td>
							</tr>																																				
						</table>
						<table border="0" width="100%">
							<tr>
								<td align="right">
								<button class="btn" accessKey=s id="btnSave" name="btnSave" onclick="javascript:doSubmit();">保存(<u>S</u>)</button>
								&nbsp;&nbsp;
								<button class="btn" accessKey=c id="btnCancel" name="btnCancel" onclick="javascript:window.returnValue=null;window.close();">取消(<u>C</u>)</button>
								&nbsp;&nbsp;								
								</td>
							</tr>
						</table>
</form>
</BODY>
</HTML>

